		<?php if(empty($id)): ?>
		<div id="sidebar">
			<ul>
				<li>
					<h3><a class="house">录入说明</a></h3>
					<ul>
						<li>客户信息资料的录入，至少需要录入姓名/性别/身份证号码，这之后才能为客户创建后续的资料文档。<br><br></li>
					</ul> 
				</li>
			</ul>
		</div>
		<?php else: ?>
		<div id="sidebar">
			<ul>
                <!--<li> <h3><a class="printer" id="printer">打印</a></h3> 
                </li>-->
                 <li> <h3><a class="download" id="download" onclick="download_pdf(<?=$id?>)">下载到本地</a></h3> 
                </li>
                <li> <h3><a class="send_mail" id="send_mail" onclick="send_to_mail(<?=$id?>)">发送到邮箱</a></h3> 
                </li>
				<li> 
					<h3><input type="checkbox" id="checkall" value="checkbox" checked="checked">全选/反选</h3> 
				</li>
                <li>
                    <h3><a class="folder_table" onclick="switch_cate_links(0)" title="展开/关闭分组">预约管理</a></h3>
                    <ul id='cate_links_0'>
                    <input type="checkbox" disabled>
                    <span style='color:#585858;cursor:pointer' onclick="window.location='<?=base_url()?>order/reservation/<?=$id?>'">预约</span>
                    </ul>
                </li>   
				<?php 
                $country_cn_names_arr = explode(",", $_SESSION['country_cn_names']);
                if(count($country_cn_names_arr) > 1) {      // 多国签证
                    $country_schengen_names_arr = explode(",", $_SESSION['country_schengen_names']);    
                    $selected_country_names_arr = array_diff($country_cn_names_arr, $country_schengen_names_arr); // 求差集，先将全部申根国家先去掉
                    $selected_country_names_arr[] = $_SESSION['main_schengen_country']; // 再将单个申根主签国放入;
                } else {
                    $selected_country_names_arr = &$country_cn_names_arr; // 单国签证;    
                }
                 
                function is_selected_country_name(&$arr, $name) {
                    foreach($arr as $v) { 
                        if(stripos($name, $v) !== false) return true;
                    }   // 判断中文名是否包含选定国家名称  
                    return false;
                }
                
                $index = 1;
                foreach($forms as $key => $val):?>
				<li>
					<h3><a class="folder_table" onclick="switch_cate_links(<?echo $index?>)" title="展开/关闭分组"><?=$key?></a></h3>
					<ul id='cate_links_<?echo $index?>'>
						<?php foreach($val as $k => $v):?>
			            <?
                         $form_table_arr = array('schengen', 'country');
                         $short_names_arr = split(",", strtolower($_SESSION['country_short_names']));
                         $arr =  explode("_", $v->table_name);
                         if( in_array($arr[0], $form_table_arr) && $arr[1] == 'cn') {
                             continue; // 过滤掉中国主表及附表
                         }
                         if( isset($arr[2]) && $arr[2]!='ext' && $arr[2]!=$_SESSION['visa_purpose'] && $arr[2]!=$_SESSION['visa_purpose'].'ex') {
                              continue; // 过滤掉签证目的类型不符的
                         }
                         if( in_array($arr[0], $form_table_arr) && !is_selected_country_name($selected_country_names_arr, $v->doc_cn_name) ) {
                             continue;  // 按中文名，过滤未选定的国家表格
                         }    
                         $form_cate = $arr[0]; // 取到表格分类的前缀名 
                         unset($arr[0]);
                        ?>
                        <li> 
						<?=($v->fill)?'<input type="checkbox" name="doc" value="'.$v->id.'" checked>':'<input type="checkbox" disabled>'?>
						<span style='color:#585858;cursor:pointer' onclick="to_url('<?=site_url( $form_cate.'/'.implode("_",$arr).'/'.$id.'/'.$v->id)?>')" title="<?=$v->doc_en_name?>_<?=$v->table_name;?>'"><?=$v->doc_cn_name?></span>
						</li>
						<?php endforeach; ?>
					</ul>
				</li>
				<?php 
                $index++;
                endforeach; ?>
			</ul>
			
		</div>  
		
		<script type="text/javascript">
        function switch_cate_links(id) {
            var obj = $('#cate_links_'+id);
            if(obj.css('display') == 'block') {
                obj.hide();    
            } else {
                obj.show();
            }  
        }
        
        function to_url(url) {
            parent.scroll(0,0);
            window.location = url
        }
        
        function generate_pdf() {
            var forms_data = []; 
            var ids = [];  
            $("#sidebar input[name=doc]:checked").each(function(){   
               ids.push($(this).val());
               forms_data.push( "{\"rel_id\":"+$(this).val()+", \"rec_id\":"+card_id+"}" );   
            }); 
            form_ids = ids.join("_"); // 此id串要传入后台备用 
            var json_data = "["+forms_data.join(",")+"]";
            //alert(json_data)
            invoke_java_servive(json_data);
        }       
        
		$().ready(function() {
			$("#checkall").click(function(){
				var ischeck=($("#checkall").attr("checked")=='checked');
				$("#sidebar input[name=doc]").each(function(){
						$(this).attr("checked", ischeck); 
					});
			});
			
			$("#printer").click(function() {
				//alert( $("#sidebar input[name=doc]:checked").size() );
				if ( $("#sidebar input[name=doc]:checked").size() == 0 ){
					alert("请选择需要打印的文档");
					return false;
				}
				var r=confirm("您确定要打印所有选择的文档吗？");
				if ( !r ) return false;
				
				
				var prt_data = [];
				$("#sidebar input[name=doc]:checked").each(function(){
					prt_data.push( {rel_id: $(this).val(), rec_id: <?=$id?>} );
				});
				
				var json_data = JSON.stringify(prt_data);
				alert("<?= 'http://'.$_SERVER['SERVER_NAME'].':9090/javaprduct/servlet/test' ?>");
				alert(json_data);
				$.post("<?=site_url('proxy/does/'.str_replace('==','',base64_encode('http://'.$_SERVER['SERVER_NAME'].':9090/javaprduct/servlet/test')))?>",{clients:json_data},function(msg){alert(msg)});
			});
			
			$("#print").ajaxError(function(event,request, settings){
				//$(this).append("<li>出错页面:" + settings.url + "</li>");
				alert("无法访问"+ settings.url );
			}); 

		});
		</script>
        
        <?=$this->load->view('user_include_pdf',null)?> 
        
        <script> in_frame = true;  // 此变量用于区分dialog的Y坐标　</script>     

		<?php endif; ?>